package com.wtwd.device.properties;


import com.wtwd.device.constant.Constant;
import com.wtwd.device.util.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "mq")
public class MqProperties {

    //消费重试次数
    private int consumeRetryTimes = 1;

    private static String APP_TOPIC_PREFIX="app_msg_";


    /**
     * mq nameServer地址
     */
    private String namesrvAddr;


    /**
     * 设备消息生产者组
     */
    private String deviceMsgProduceGroup;

    /**
     * 设备消息生产者主题
     */
    private String deviceMsgProduceTopic;

    /**
     * 设备消息标签
     */
    private String deviceMsgTag;

    /**
     * 设备服务器消费者组
     */
    private String deviceMsgConsumeGroup;

    /**
     * 设备服务器处理生产者组
     */
    private String deviceServiceProduceGroup;

    /**
     * 设备服务器处理消费者组
     */
    private String deviceServiceConsumeGroup;

    /**
     * 设备服务器消费主题
     */
    private String deviceConsumeTopic;

    /**
     * app消息生产者组
     */
    private String appMsgProduceGroup;

    private String appMsgConsumeGroup;

    private String appMsgConsumeTopic;

    private String appMsgTag;

    public String getAppMsgConsumeTopic() {
        return APP_TOPIC_PREFIX.concat(String.valueOf(StringUtils.ipToLong(Constant.LOCAL_IP)));
    }

    public void setAppMsgConsumeTopic(String appMsgConsumeTopic) {
        this.appMsgConsumeTopic = appMsgConsumeTopic;
    }

    public String getAppMsgConsumeGroup() {
        return appMsgConsumeGroup;
    }

    public void setAppMsgConsumeGroup(String appMsgConsumeGroup) {
        this.appMsgConsumeGroup = appMsgConsumeGroup;
    }

    public String getAppMsgProduceGroup() {
        return appMsgProduceGroup;
    }

    public void setAppMsgProduceGroup(String appMsgProduceGroup) {
        this.appMsgProduceGroup = appMsgProduceGroup;
    }

    public String getAppMsgTag() {
        return appMsgTag;
    }

    public void setAppMsgTag(String appMsgTag) {
        this.appMsgTag = appMsgTag;
    }

    public String getDeviceConsumeTopic() {
        return String.valueOf(StringUtils.ipToLong(Constant.LOCAL_IP));
    }

    public void setDeviceConsumeTopic(String deviceConsumeTopic) {
        this.deviceConsumeTopic = deviceConsumeTopic;
    }

    public String getDeviceServiceConsumeGroup() {
        return deviceServiceConsumeGroup;
    }

    public void setDeviceServiceConsumeGroup(String deviceServiceConsumeGroup) {
        this.deviceServiceConsumeGroup = deviceServiceConsumeGroup;
    }

    public String getNamesrvAddr() {
        return namesrvAddr;
    }

    public void setNamesrvAddr(String namesrvAddr) {
        this.namesrvAddr = namesrvAddr;
    }

    public String getDeviceMsgProduceGroup() {
        return deviceMsgProduceGroup;
    }

    public void setDeviceMsgProduceGroup(String deviceMsgProduceGroup) {
        this.deviceMsgProduceGroup = deviceMsgProduceGroup;
    }

    public String getDeviceMsgProduceTopic() {
        return deviceMsgProduceTopic;
    }

    public void setDeviceMsgProduceTopic(String deviceMsgProduceTopic) {
        this.deviceMsgProduceTopic = deviceMsgProduceTopic;
    }

    public String getDeviceMsgTag() {
        return deviceMsgTag;
    }

    public void setDeviceMsgTag(String deviceMsgTag) {
        this.deviceMsgTag = deviceMsgTag;
    }

    public String getDeviceMsgConsumeGroup() {
        return deviceMsgConsumeGroup;
    }

    public void setDeviceMsgConsumeGroup(String deviceMsgConsumeGroup) {
        this.deviceMsgConsumeGroup = deviceMsgConsumeGroup;
    }

    public int getConsumeRetryTimes() {
        return consumeRetryTimes;
    }

    public void setConsumeRetryTimes(int consumeRetryTimes) {
        this.consumeRetryTimes = consumeRetryTimes;
    }

    public String getDeviceServiceProduceGroup() {
        return deviceServiceProduceGroup;
    }

    public void setDeviceServiceProduceGroup(String deviceServiceProduceGroup) {
        this.deviceServiceProduceGroup = deviceServiceProduceGroup;
    }

    public static String getAppTopic(){
        return APP_TOPIC_PREFIX.concat(String.valueOf(StringUtils.ipToLong(Constant.LOCAL_IP)));
    }
    @Override
    public String toString() {
        return "MqProperties{" +
                "consumeRetryTimes=" + consumeRetryTimes +
                ", namesrvAddr='" + namesrvAddr + '\'' +
                ", deviceMsgProduceGroup='" + deviceMsgProduceGroup + '\'' +
                ", deviceMsgProduceTopic='" + deviceMsgProduceTopic + '\'' +
                ", deviceMsgTag='" + deviceMsgTag + '\'' +
                ", deviceMsgConsumeGroup='" + deviceMsgConsumeGroup + '\'' +
                ", deviceServiceProduceGroup='" + deviceServiceProduceGroup + '\'' +
                ", deviceServiceConsumeGroup='" + deviceServiceConsumeGroup + '\'' +
                ", deviceConsumeTopic='" + deviceConsumeTopic + '\'' +
                ", appMsgProduceGroup='" + appMsgProduceGroup + '\'' +
                ", appMsgTag='" + appMsgTag + '\'' +
                '}';
    }
}
